package simportal.controller;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;

import simportal.service.RoleService;

import com.cfuture08.eweb4j.component.DivPageComp;
import com.cfuture08.eweb4j.ioc.IOC;
import com.cfuture08.eweb4j.mvc.annotation.Controller;
import com.cfuture08.eweb4j.mvc.annotation.Param;
import com.cfuture08.eweb4j.mvc.annotation.RequestMapping;
import com.cfuture08.eweb4j.mvc.annotation.Result;
import com.cfuture08.eweb4j.mvc.annotation.Singleton;

/**
 * 角色-控制器 1.分配权限 2.新增角色 3.修改角色 4.删除角色 5.查看角色详细 6.查看角色列表 7.查询角色信息
 * 
 * @author weiwei[l.weiwei@163.com]
 * 
 */
@Controller
@Singleton
public class RoleControl {
	private final static RoleService service = IOC.getBean("RoleSerivce");

	@RequestMapping("webadmin/roles/list")
	@Result(location = { "list.jsp" }, name = { "success" }, type = { "" })
	public String list(@Param("pageNum") int pageNum,
			@Param("numPerPage") int numPerPage, HttpServletRequest request) {
		request.setAttribute("roles", service.getPage(pageNum, numPerPage));
		DivPageComp dpc = new DivPageComp(pageNum, numPerPage, service.countAll(), 9);
		dpc.setLocation("list?pageNum={pageNum}&numPerPage=" + numPerPage);
		dpc.doWork();
		request.setAttribute("dpc", dpc);
		return "success";
	}
	
	@RequestMapping("test")
	public String test(PrintWriter out){
		out.print("test");
		return "ajax";
	}
}
